package com.jt.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.env.Environment;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.nio.channels.ReadableByteChannel;

@Component
public class TestServcie implements  ResourceLoaderAware {

    @Value("${spring.datasource.url}")
    private  String  url;

    @Override
    public void setResourceLoader(ResourceLoader resourceLoader) {
        Resource resource = resourceLoader.getResource("classpath:application.yml");

        try {
            ReadableByteChannel readableByteChannel = resource.readableChannel();

            System.out.println(readableByteChannel);
        } catch (IOException e) {
            e.printStackTrace();
        }

        String description = resource.getDescription();
        try {
            long l = resource.contentLength();
        } catch (IOException e) {
            e.printStackTrace();
        }


        System.out.println("资源加载完毕");
    }
}
